﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Workflow2211A.Consol.Steps;
using WorkflowCore.Interface;

namespace Workflow2211A.Consol.Workflows
{
    /// <summary>
    /// 输出
    /// </summary>
    public class OutcomeWorkflow : IWorkflow
    {
        public string Id => nameof(OutcomeWorkflow);

        public int Version => 1;

        //需求：在步骤中生成随机数（1，0两个数）后返回，
        //当等于0时重新执行此步骤，当等于1时流程结束。
        public void Build(IWorkflowBuilder<object> builder)
        {
            //Outcome 一般用来表述流程的分支 与When 一起使用
            builder.StartWith<StartStep>()
                   .Then<RandStep>(x =>
                   {
                       x.When(0).Then(x)
                        .When(1).Then<EndStep>();
                   });
        }
    }
}
